function _slicedToArray(e, t) {
    return _arrayWithHoles(e) || _iterableToArrayLimit(e, t) || _nonIterableRest();
}

function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance");
}

function _iterableToArrayLimit(e, t) {
    var r = [], n = !0, i = !1, o = void 0;
    try {
        for (var a, u = e[Symbol.iterator](); !(n = (a = u.next()).done) && (r.push(a.value), 
        !t || r.length !== t); n = !0) ;
    } catch (e) {
        i = !0, o = e;
    } finally {
        try {
            n || null == u.return || u.return();
        } finally {
            if (i) throw o;
        }
    }
    return r;
}

function _arrayWithHoles(e) {
    if (Array.isArray(e)) return e;
}

function _typeof(e) {
    return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
        return typeof e;
    } : function(e) {
        return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
    })(e);
}

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var MILLISECONDS_PER_DAY = 864e5;

function isEmptyObject(e) {
    return !Object.keys(e).length;
}

function formatDate(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "/";
    return [ e.getFullYear(), e.getMonth() + 1, e.getDate() ].map(formatNumber).join(t);
}

function formatTime(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "/", r = e.getHours(), n = e.getMinutes(), i = e.getSeconds();
    return formatDate(e, t) + " " + [ r, n, i ].map(formatNumber).join(":");
}

function getTimeToLocal(e) {
    void 0 === e && (e = new Date().getHours());
    switch (!0) {
      case 0 <= e && e <= 5:
        return "凌晨";

      case 5 < e && e <= 9:
        return "早上";

      case 9 < e && e <= 11:
        return "上午";

      case 11 < e && e <= 14:
        return "中午";

      case 14 < e && e <= 18:
        return "下午";

      case 18 < e && e <= 23:
        return "晚上";
    }
}

function humanizeTime(e) {
    var t = [ (e = new Date(e)).getHours(), e.getMinutes() ].map(formatNumber).join(":");
    return isToday(e) ? "今天".concat(t) : isYesterday(e) ? "昨天".concat(t) : formatDate(e);
}

function getDate(e, t) {
    return "string" == typeof e ? new Date(e.replace(/-/g, "/")) : isDate(e) ? e : new Date(e * (t ? 1 : 1e3));
}

function formatTimeStamp(e) {
    for (var t = getDate(e, 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 1), r = Math.ceil((new Date().getTime() - t.getTime()) / 1e3), n = [ "86400", "3600", "60", "1" ], i = {
        86400: "天",
        3600: "小时",
        60: "分钟",
        1: "秒"
    }, o = 0; o < n.length; o++) {
        var a = n[o], u = Math.floor(r / Number(a));
        if (0 !== u) return "86400" === a ? 1 === u ? "昨天" : formatDate(t, "-") : u + i[a] + "前";
    }
}

function isToday(e) {
    var t = new Date();
    return e = new Date(e), t.setHours(0, 0, 0, 0) === e.setHours(0, 0, 0, 0);
}

function isYesterday(e) {
    var t = new Date(), r = new Date(t.getTime() - MILLISECONDS_PER_DAY);
    return e = new Date(e), r.setHours(0, 0, 0, 0) === e.setHours(0, 0, 0, 0);
}

var getType = function(e) {
    return Object.prototype.toString.call(e);
}, isDate = function(e) {
    return "[object Date]" === getType(e);
}, isFunction = function(e) {
    return "function" == typeof e;
};

function formatLocalDate(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "Y年M月D日 h:m:s", r = getDate(e, 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : 1), n = {
        Y: r.getFullYear(),
        M: formatNumber(r.getMonth() + 1),
        D: formatNumber(r.getDate()),
        h: formatNumber(r.getHours()),
        m: formatNumber(r.getMinutes()),
        s: formatNumber(r.getSeconds())
    };
    return t.replace(/Y|M|D|h|m|s/g, function(e) {
        return n[e];
    });
}

function formatNumber(e) {
    return (e = e.toString())[1] ? e : "0" + e;
}

function convertNumber(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "en";
    if (null == e) return 0;
    e = e.toString();
    var r = [ "千", "万", "0万", "00万", "000万", "亿" ];
    return {
        en: function() {
            return 5 <= e.length ? e.slice(0, -3) + "k+" : e;
        },
        cn: function() {
            return 4 <= e.length ? e.slice(0, 1) + r[e.length - 4] + "+" : e;
        }
    }[t]();
}

function formatDecimal() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : "";
    return (e = (e = (e = "" + e).replace(/^\./g, "0.")).replace(/\.{2,}/g, ".")).replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
}

function isVerifyCode(e) {
    return /^\d{4}$/.test(e);
}

function isMobile(e) {
    return /^1\d{10}$/.test(e);
}

function isEmail(e) {
    return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e);
}

function isWechat(e) {
    return /[A-Za-z0-9\-\_]/g.test(e);
}

function isNum(e) {
    return /^[0-9-]*$/.test(e);
}

function isTel(e) {
    return /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(e);
}

function isChn(e) {
    return /^[\u4E00-\u9FA5]+$/.test(e);
}

function isPrice(e) {
    return /(^[1-9](\d+)?(\.\d{1,2})?$)|(^(0){1}$)|(^\d\.\d{1,2}?$)/.test(e);
}

function isPositiveInt(e) {
    return /^[1-9][0-9]*$/.test(e);
}

function formatMobile(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "-";
    return "".concat(e.slice(0, 3)).concat(t).concat(e.slice(3, 7)).concat(t).concat(e.slice(7));
}

function formatInputMobile(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : " ", r = e.length, n = [ e.slice(0, 3) ];
    return 3 < r && n.push(e.slice(3, 7)), 7 < r && n.push(e.slice(7)), n.join(t);
}

function getByteLength(e) {
    if (void 0 === e) return 0;
    var t = e.match(/[^\x00-\x80]/g);
    return e.length + (t ? t.length : 0);
}

function sliceByByte(e, t) {
    for (var r = "", n = 0, i = 0, o = e.length; i < o && !(t <= n / 2); i++) n = getByteLength(r += e[i]);
    return r;
}

function filterEmoji(e) {
    var t = new RegExp("(?:[✀-➿]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[#-9]️?⃣|㊙|㊗|〽|〰|Ⓜ|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|🆎|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|🈚|🈯|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|‼|⁉|[▪-▫]|▶|◀|[◻-◾]|©|®|™|ℹ|🀄|[☀-⛿]|⬅|⬆|⬇|⬛|⬜|⭐|⭕|⌚|⌛|⌨|⏏|[⏩-⏳]|[⏸-⏺]|🃏|⤴|⤵|[←-⇿])", "g");
    return e.replace(t, "");
}

function serialize(t) {
    return Object.keys(t).sort().map(function(e) {
        return "".concat(e, "=").concat(t[e]);
    }).join("&");
}

function clipImage(e, t) {
    if (/^https?:\/\/img.ibos.cn/.test(e)) {
        /@\d*[wh](_\d*[wh])?/.test(e) && (e = e.replace(/@\d*[wh](_\d*[wh])?_1c_1e/g, ""));
        var r = e.indexOf("?");
        return ~r ? e.slice(0, r) + "@" + t + e.slice(r) : e + "@" + t;
    }
    return e;
}

function ucFirst(e) {
    return "string" == typeof e ? e.slice(0, 1).toUpperCase() + e.slice(1) : e;
}

function getAvatar(e, t) {
    return clipImage(e, t);
}

function chunk(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 3;
    if (!e || !e.length) return [];
    for (var r = [], n = 0; n <= e.length; n += t) r.push(e.slice(n, n + t));
    return r;
}

function clearBOMAndParseJson(e) {
    if ("string" == typeof e) try {
        return JSON.parse(e.trim());
    } catch (e) {
        return {};
    }
    return e;
}

var isObject = function(e) {
    var t = _typeof(e);
    return "function" === t || "object" === t && !!e;
}, allKeys = function(e) {
    if (!isObject(e)) return [];
    var t = [];
    for (var r in e) t.push(r);
    return t;
}, createAssigner = function(s, c) {
    return function(e) {
        var t = arguments.length;
        if (t < 2 || null == e) return e;
        for (var r = 1; r < t; r++) for (var n = arguments[r], i = s(n), o = i.length, a = 0; a < o; a++) {
            var u = i[a];
            c && void 0 !== e[u] || (e[u] = n[u]);
        }
        return e;
    };
}, extend = createAssigner(allKeys), STAR_NAME = "星标好友";

function groupByKey(e, r, n) {
    var i = [], o = {}, t = extend([], e);
    return t.sort(function(e, t) {
        return e.istop !== t.istop ? e.istop < t.istop ? 1 : -1 : e[r] < t[r] ? 1 : -1;
    }), t.forEach(function(e) {
        var t = e[r];
        +e.istop && (t = STAR_NAME), n && n(t, e), o[t] || (o[t] = [], i.push(t)), o[t].push(e);
    }), {
        groupedList: o,
        groupedKeys: i
    };
}

function groupByLetterKey(e, t, r) {
    return groupByKey(e, t, r);
}

function groupByTimestampDesc(e, n) {
    var i = [], o = {}, t = extend([], e);
    return t.sort(function(e, t) {
        return e.istop !== t.istop ? e.istop < t.istop ? 1 : -1 : e[n] < t[n] ? 1 : -1;
    }), t.forEach(function(e) {
        var t, r = new Date(1e3 * e[n]);
        t = +e.istop ? STAR_NAME : isToday(r) ? "今天" : isYesterday(r) ? "昨天" : formatDate(r, "-"), 
        o[t] || (o[t] = [], i.push(t)), o[t].push(e);
    }), {
        groupedKeys: i,
        groupedList: o
    };
}

function qAlert() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : "", t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "", r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : "确定";
    return wx.showModal({
        title: t,
        content: e,
        confirmText: r,
        showCancel: !1
    });
}

function requestFailTip(e, t) {
    var r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : "网络不稳定，请尝试下拉页面刷新";
    console.log("request error", e);
    e && [ "request:fail:interrupted", "request:fail interrupted", "request:fail createRequestTask:fail:interrupted" ].includes(e.errMsg) ? console.log("由小程序退出而引起的网络中退") : qAlert(r, t);
}

function showTips(t) {
    wx.showModal(Object.assign({}, t, {
        success: function(e) {
            e.confirm && t.success && t.success();
        }
    }));
}

function addThumbToData(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "avatar", r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : 100;
    return e[t + "Thumb"] = getAvatar(e[t], "".concat(r, "h_").concat(r, "w_1e_1c")), 
    e;
}

function addThumbToList(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "avatar", r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : 100;
    return e.forEach(function(e) {
        e = addThumbToData(e, t, r);
    }), e;
}

function parseUrl() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : "";
    e = e.substr("/" === e.charAt(0) ? 1 : 0);
    var i = {}, t = _slicedToArray(e.split("?"), 2), r = t[0], n = t[1];
    return n && n.split("&").forEach(function(e) {
        var t = _slicedToArray(e.split("="), 2), r = t[0], n = t[1];
        i[r] = n;
    }), {
        url: r,
        query: i
    };
}

function sliceStr() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : "", t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 10, r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : "...";
    return e.length > t ? e.slice(0, t) + r : e;
}

function getExtname(e) {
    var t = (e += "").lastIndexOf(".");
    return -1 !== t ? e.slice(t + 1) : "";
}

function getFileType(e) {
    var t = "";
    return e = getExtname(e), /pdf/.test(e) ? t = "pdf" : /doc|docx/.test(e) ? t = "doc" : /ppt|pps|pptx/.test(e) ? t = "ppt" : /xls|xlsx|xlsm|xlt|xltx|xltm/.test(e) && (t = "xls"), 
    t;
}

function getFileSize(e) {
    var t = [ "Byte", "K", "M", "G" ], r = 0;
    for (e = Math.max(parseInt(e, 10) || 0, 0); 1024 <= e && r < t.length - 1; ) e /= 1024, 
    r++;
    return +e.toFixed(1) + t[r];
}

function transformCamel(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "-", r = new RegExp("".concat(t, "(\\w)"), "g");
    return e.replace(r, function(e, t) {
        return t.toUpperCase();
    });
}

function parseLaunchQueryString(e) {
    if ("object" === _typeof(e)) return e;
    if ("string" != typeof e) return {};
    e = e.replace(/[{}]/g, "");
    var i = {};
    return e.split(",").forEach(function(e) {
        var t = _slicedToArray(e.split("="), 2), r = t[0], n = t[1];
        i[r] = n;
    }), i;
}

function deepClone(e, t) {
    var r = t || {};
    for (var n in e) if (e.hasOwnProperty(n)) {
        var i = e[n];
        if (i === r) continue;
        "object" === _typeof(i) ? r[n] = i.constructor === Array ? [] : Object.create(i) : r[n] = i;
    }
    return r;
}

var _default = {
    isEmptyObject: isEmptyObject,
    extend: extend,
    formatNumber: formatNumber,
    formatDate: formatDate,
    formatTime: formatTime,
    getTimeToLocal: getTimeToLocal,
    formatLocalDate: formatLocalDate,
    formatDecimal: formatDecimal,
    humanizeTime: humanizeTime,
    isVerifyCode: isVerifyCode,
    isDate: isDate,
    isFunction: isFunction,
    isToday: isToday,
    isYesterday: isYesterday,
    isMobile: isMobile,
    isWechat: isWechat,
    isEmail: isEmail,
    isChn: isChn,
    isNum: isNum,
    isTel: isTel,
    isPrice: isPrice,
    isPositiveInt: isPositiveInt,
    chunk: chunk,
    clearBOMAndParseJson: clearBOMAndParseJson,
    formatMobile: formatMobile,
    formatInputMobile: formatInputMobile,
    ucFirst: ucFirst,
    serialize: serialize,
    clipImage: clipImage,
    getAvatar: getAvatar,
    groupByKey: groupByKey,
    groupByLetterKey: groupByLetterKey,
    groupByTimestampDesc: groupByTimestampDesc,
    isObject: isObject,
    allKeys: allKeys,
    qAlert: qAlert,
    requestFailTip: requestFailTip,
    convertNumber: convertNumber,
    filterEmoji: filterEmoji,
    getByteLength: getByteLength,
    sliceByByte: sliceByByte,
    formatTimeStamp: formatTimeStamp,
    showTips: showTips,
    addThumbToData: addThumbToData,
    addThumbToList: addThumbToList,
    parseUrl: parseUrl,
    sliceStr: sliceStr,
    getExtname: getExtname,
    getFileType: getFileType,
    getFileSize: getFileSize,
    transformCamel: transformCamel,
    parseLaunchQueryString: parseLaunchQueryString,
    deepClone: deepClone
};

exports.default = _default;